package org.example.taskmaster;

import android.database.Cursor;

public class Task {
	private String name;
	private String list;
	private String notes;
	private int complete;
	private int dueYear;
	private int dueMonth;
	private int dueDay;
	private int dueHour;
	private int dueMinute;
	
	public Task(Cursor cursor) {
    	// KEY_ROWID, KEY_NAME, KEY_LIST, KEY_NOTES, KEY_YEAR4, KEY_MONTH, KEY_DAY, KEY_HOUR7, KEY_MINUTE, KEY_COMPLETE
    	setName(cursor.getString(1));
    	setList(cursor.getString(2));
    	setNotes(cursor.getString(3));
    	setDueYear(cursor.getInt(4));
    	setDueMonth(cursor.getInt(5));
    	setDueDay(cursor.getInt(6));    	
    	setDueHour(cursor.getInt(7));
    	setDueMinute(cursor.getInt(8));
    	setComplete(cursor.getInt(9));
	}
	public Task(String name) {
		this.name = name;
		this.list = "default list";
		this.notes = "default notes";
		this.complete = 0;
		this.dueYear = 34;
		this.dueMonth = 2;
		this.dueDay = 1;
		this.dueHour = 12;
		this.dueMinute = 0;
	}
	// Getters and Setters
	
	public String getName() {
		return name;
	}
	public int isComplete() {
		return complete;
	}

	public void setComplete(int complete) {
		this.complete = complete;
	}

	public int getDueHour() {
		return dueHour;
	}

	public void setDueHour(int dueHour) {
		this.dueHour = dueHour;
	}

	public int getDueMinute() {
		return dueMinute;
	}

	public void setDueMinute(int dueMinute) {
		this.dueMinute = dueMinute;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getList() {
		return list;
	}
	public void setList(String list) {
		this.list = list;
	}
	public int getDueYear() {
		return dueYear;
	}
	public void setDueYear(int dueYear) {
		this.dueYear = dueYear;
	}
	public int getDueMonth() {
		return dueMonth;
	}
	public void setDueMonth(int dueMonth) {
		this.dueMonth = dueMonth;
	}
	public int getDueDay() {
		return dueDay;
	}
	public void setDueDay(int dueDay) {
		this.dueDay = dueDay;
	}
	public String getNotes() {
		return notes;
	}
	public void setNotes(String notes) {
		this.notes = notes;
	}
	public String getDate() {
		String date = Integer.toString(this.dueDay) + "-" +
					  Integer.toString(this.dueMonth)+ "-" +
					  Integer.toString(this.dueYear);
		return date;		
	}
	public String getTime() {
		String time = pad(this.dueHour) + ":" + 
					  pad(this.dueMinute);
		return time;
	}
	private static String pad(int c) {
	    if (c >= 10)
	        return String.valueOf(c);
	    else
	        return "0" + String.valueOf(c);
	}

}
